Using JSP taglib
for paging
Step 1 download jsp taglib from
http://jsptags.com/tags/navigation/pager/download.jspStep 2
Copy pager-taglib.tld in WEB-INF directory of web application
Copy pager-taglib.jar in WEB-INF/lib directory of web application
Step 3 Define tld in web.xml
<taglib>
<taglib-uri>http://jsptags.com/tags/navigation/pager</taglib-uri>
<taglib-location>/WEB-INF/pager-taglib.tld</taglib-location>
</taglib>
Step 4 Define the tag lib in jsp
<%@ taglib uri="/WEB-INF/pager-taglib.tld" prefix="pg" %>
Step 5 Define number of pages to display etc in jsp
<pg:pager maxIndexPages="10"
maxPageItems="10"
export="pagerPageNumber=pageNumber" >
<!-- pagerPageNumber is used by me in the logic to display the current page in different color with out link-->
Step 6 Create a loop for displaying data
<% while (crs.next())
<!—where crs is cached row set, this object must be ArrayList, Vector, Collection, ResultSet which can be scrolled -- >
<pg:item>
{
%>
<% out.print(crs.getString("L820FIRM").trim()); %>
<%
}
%>
</pg:item>
Step 7 Logic to display the page numbers and next page and previous page arrows for navigation
<pg:index>
<pg:prev>
<a href="<%=pageUrl%>" <!-- some image text to display navigation to previous page -- > < </a>
</pg:prev>
<pg:pages>
if (pageNumber == pagerPageNumber)
{
// same page so no link here
<%=pageNumber%>
}
else
{
// other pages where the user can jump
<a href="<%=pageUrl%>" ><%= pageNumber %></a>
}
</pg:pages>
<pg:next>
<a href="<%=pageUrl%>" <!-- some image text to display navigation to next page > -- > > </a>
</pg:next>
</pg:index>
Step 8 end of pager taglib
</pg:pager>
More documentation can be found at
http://jsptags.com/tags/navigation/pager/pager-taglib-2.0.html